
package projet_isep;

import java.util.ArrayList;

public class Resultats 
{
    public static void resultats(int[][] grille) 
    {
            ArrayList<Integer> listeJetons = new ArrayList<Integer>();
            ArrayList<Integer> listeJetons2 = new ArrayList<Integer>();

            for (int i = 0; i < grille.length; i++) {
                for (int j = 0; j < grille.length; j++) {
                    if (grille[i][j] != -1 && grille[i][j] != 0)
                        listeJetons.add(grille[i][j]);
                }
            }
            System.out.println(listeJetons);


            for(int m = listeJetons.size() - 1; m >= 0; m--)
                listeJetons2.add(listeJetons.get(m));

            System.out.println(listeJetons2);

            System.out.println(scoreFinal(listeJetons));
            System.out.println(scoreFinal(listeJetons2));

            if(scoreFinal(listeJetons) >= scoreFinal(listeJetons2))
                System.out.println("Votre score est de " + scoreFinal(listeJetons) + " !");
            else
                System.out.println("Votre score est de " + scoreFinal(listeJetons2) + " !");
    }
        
    public static int scoreFinal(ArrayList<Integer> listeJetons) 
    {
        int cpt = 1;
        ArrayList<Integer> sequences = new ArrayList<Integer>();
        ArrayList<Integer> score = new ArrayList<Integer>();
        
        for (int j = 0; j < listeJetons.size() - 1; j++) {
            if ((listeJetons.get(j) <= listeJetons.get(j + 1)) || (listeJetons.get(j) == 666)) {
                cpt++;
            } else {
                sequences.add(cpt);
                cpt = 1;
            }
        }
        sequences.add(cpt);

        System.out.println(sequences);

        for (int k = 0; k < sequences.size(); k++) 
        {
            int x = sequences.get(k);
            switch (x) 
            {
                case 1: score.add(0); break;
                case 2: score.add(1); break;
                case 3: score.add(3); break;
                case 4: score.add(5); break;
                case 5: score.add(7); break;
                case 6: score.add(9); break;
                case 7: score.add(11); break;
                case 8: score.add(15); break;
                case 9: score.add(20); break;
                case 10: score.add(25); break;
                case 11: score.add(30); break;
                case 12: score.add(35); break;
                case 13: score.add(40); break;
                case 14: score.add(50); break;
                case 15: score.add(60); break;
                case 16: score.add(70); break;
                case 17: score.add(85); break;
                case 18: score.add(100); break;
                case 19: score.add(150); break;
                case 20: score.add(300); break;
            }
        }
        System.out.println(score);
        
        int scoreFinal = 0;
        for(int l = 0; l < score.size(); l++)
        {
            scoreFinal += score.get(l);
        }
        return scoreFinal;
    }
    
}
